/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 direction.h

	$Header: /heroes4/direction.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( DIRECTION_H_INCLUDED )
#define DIRECTION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>

struct t_map_point_2d;

// ----------------------------------------------------------------------
// t_direction enum
// ----------------------------------------------------------------------

enum t_direction
{
	k_direction_northeast,
	k_direction_east,
	k_direction_southeast,
	k_direction_south,
	k_direction_southwest,
	k_direction_west,
	k_direction_northwest,
	k_direction_north,

	k_direction_count,
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
std::string const & get_direction_name( t_direction direction );

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
t_map_point_2d const & get_direction_offset( t_direction direction );


// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
inline bool is_diagonal( t_direction direction )
{
	return ( direction & 1 ) != 0;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
inline t_direction opposite( t_direction direction )
{
	return t_direction( ( direction + k_direction_count / 2 ) & (k_direction_count - 1) );
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
inline t_direction clockwise( t_direction direction, int increment = 1 )
{
	return t_direction( ( direction + increment ) & (k_direction_count - 1) );
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
inline t_direction counter_clockwise( t_direction direction, int increment = 1 )
{
	return t_direction( ( direction - increment ) & (k_direction_count - 1) );
}

#endif // !defined( DIRECTION_H_INCLUDED )
